package com.hive.decode;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * 获取hive连接
 */
public class HiveConn {


    public static Connection conn=null;

    public static Connection getConn()throws Exception{

        if(conn==null){
            Class.forName("org.apache.hive.jdbc.HiveDriver");
            conn=  DriverManager.getConnection("jdbc:hive2://10.1.1.153:10000/group/user/tools/meta//old-hive/test2","hive","hive");
        }
        return conn;
    }

    public static void close(Connection conn){
        if(conn!=null){
            try {
                conn.close();
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

}
